package com.example.zselasticsearchsf.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.example.zselasticsearchsf.domain.CaseInfoBean;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @Author: Steven
 * @Date: 2021/12/1 15:40
 */

public interface CaseInfoMapper extends BaseMapper<CaseInfoBean> {
    @Select(" select info.CASE_ID,info.CASE_TITLE,type.TYPE_NAME as TYPE_ID,col.CLOUMN_NAME as COLUMN_ID,dic.DIC_NAME as TEXT_TYPE,info.SOURCE,info.AUTHOR,\n" +
            "               info.SYBIOSIS,info.CONTEXT,info.UPLOAD_DEPT_ID,dept.DEPT_FULL_NAME as UPLOAD_DEPT_NAME,DATE_FORMAT(info.UPLOAD_DATE,'%Y-%m-%d %H:%i:%s') as UPLOAD_DATE,info.IS_PUBLISH,\n" +
            "               DATE_FORMAT(info.PUBLISH_DATE,'%Y-%m-%d %H:%i:%s') as PUBLISH_DATE,info.PUBLISH_HAIR,info.APPROVE_START,info.APPROVER,DATE_FORMAT(info.APPROVE_DATE,'%Y-%m-%d %H:%i:%s') as APPROVE_DATE,\n" +
            "               info.KEYWORD,info.IS_TOPPING,info.IS_ACTIVE,info.CREATOR,DATE_FORMAT(info.CREATE_TIME,'%Y-%m-%d %H:%i:%s') as CREATE_TIME,info.UPDATOR,\n" +
            "               DATE_FORMAT(info.UPDATE_TIME,'%Y-%m-%d %H:%i:%s') as UPDATE_TIME,info.IS_POPULARIZE_LAW,info.IS_LEGALITY,info.TAG_INFO,info.CLICK_RATE,info.DIST_CODE,dist.DIST_NAME as DIST_NAME\n" +
            "        from sf_case_info info\n" +
            "                 left join sf_case_business_type type on info.TYPE_ID = type.TYPE_ID and type.IS_ACTIVE = '1'\n" +
            "                 left join sf_case_column col on info.COLUMN_ID = col.COLUMN_ID and col.IS_ACTIVE = '1'\n" +
            "                 left join spb_dicinfo dic on info.TEXT_TYPE = dic.DIC_CODE and dic.IS_ACTIVE = '1'\n" +
            "                 left join sog_dept dept on info.UPLOAD_DEPT_ID = dept.DEPT_ID and dept.IS_ACTIVE = '1'\n" +
            "                 left join sog_dist dist on info.dist_code = dist.DIST_ID and dist.IS_ACTIVE = '1'")
    List<Map<String, Object>> selectEsCaseInfo();
    @Select(" select info.CONTEXT_ID,info.CONTEXT_TITLE,info.CONTEXT_SUBTITLE,menu.MENU_NAME as COLUMN_ID,info.AUTHOR,info.IS_PUBLISH,\n" +
            "               DATE_FORMAT(info.PUBLISH_DATE,'%Y-%m-%d %H:%i:%s') as PUBLISH_DATE,info.SOURCE,info.SYBIOSIS,info.CONTEXT,info.IS_TOPPING,\n" +
            "               info.DIST_CODE,dist.DIST_NAME as DIST_NAME,info.AUDITOR,info.AUDIT_START,DATE_FORMAT(info.AUDIT_DATE,'%Y-%m-%d %H:%i:%s') as AUDIT_DATE,info.PUBLISH_HAIR,info.UPLOAD_DEPT_ID,dept.DEPT_FULL_NAME as UPLOAD_DEPT_NAME,info.IS_ACTIVE,info.CREATOR,\n" +
            "               DATE_FORMAT(info.CREATE_TIME,'%Y-%m-%d %H:%i:%s') as CREATE_TIME,info.UPDATOR,DATE_FORMAT(info.UPDATE_TIME,'%Y-%m-%d %H:%i:%s') as UPDATE_TIME,\n" +
            "               info.AUDIT_IDEA,attac.CLICK_RATE,attac.TAG_INFO\n" +
            "        from p_context_info info\n" +
            "                 left join s_menu menu on info.COLUMN_ID = menu.MENU_ID and menu.IS_ACTIVE = '1'\n" +
            "                 left join sog_dist dist on info.dist_code = dist.DIST_ID and dist.IS_ACTIVE = '1'\n" +
            "                 left join sog_dept dept on info.UPLOAD_DEPT_ID = dept.DEPT_ID and dept.IS_ACTIVE = '1'\n" +
            "                 left join p_context_attached attac on info.CONTEXT_ID = attac.CONTEXT_ID and attac.IS_ACTIVE = '1'")
    List<Map<String, Object>> selectEsPublicInfo();
}
